//
//  HENoticeTagCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/12/31.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HENoticeTagCell.h"
#import "HEHealthAlarmModel.h"

@interface HENoticeTagCell ()<QMUITextFieldDelegate>

@property (nonatomic, strong) UILabel *titleLb;

@property (nonatomic, strong) QMUITextField *contentTF;
@property (nonatomic, strong) HEHealthAlarmModel *model;

@end

@implementation HENoticeTagCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    _titleLb = [[UILabel alloc] init];
    _titleLb.font = DYFont(15);
    _titleLb.text = @"标签";
    _titleLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview:_titleLb];
 
    _contentTF = [[QMUITextField alloc] init];
    _contentTF.font = DYFont(16);
    _contentTF.placeholder = @"请选择提醒标签";
    _contentTF.textColor = CNavLightBlackColor;
    _contentTF.delegate = self;
    [self.contentView addSubview: _contentTF];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_contentTF);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [_titleLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [_contentTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(_titleLb.mas_right).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
    }];
}

- (void)configCellWithModel:(HEHealthAlarmModel *)model indexPath:(NSIndexPath *)indexPath {
    _model = model;
    _contentTF.text = model.alarm_title;
}

#pragma mark - TextFiledDelegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

    NSString *text = [textField.text stringByReplacingCharactersInRange:range withString:string];
    _model.alarm_title = text;
    return YES;
}

@end
